package com.matrix.java.chap_06;

import java.util.Scanner;

/*
    财务应用程序：计算未来投资价值
    未来投资金额 =投资总额 X ( 1 +月利率）
 */
public class Ex6_07 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("The amount invested: ");
        double amount = input.nextDouble();
        System.out.print("Annual interest rate: ");
        double rate = input.nextDouble();
        input.close();
        double monthlyInterestRate = rate / 1200;
        System.out.println("Years   Future Value");
        for (int i = 1; i <= 30; i++) {
            double value = futurelnvestmentValue(amount, monthlyInterestRate, i);
            System.out.printf("%d%s%.2f%n", i, "        ", value);
        }
    }

    public static double futurelnvestmentValue(
            double investmentAmount, double monthlyInterestRate, int years) {
        double value;
        value = investmentAmount * Math.pow((1 + monthlyInterestRate), (years * 12));
        return value;
    }
}
